package aop.xyz.myapp.article;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

import aop.xyz.myapp.domain.account.Article;

@Aspect
public class BeforeAdvice {
	public static final String BEFORE_SAVE = "Before save advice executed.";

	public static String status;

	@Before("aop.xyz.myapp.article.PointCuts.bizService() && args(article)")
	public void ChangeNullStringToEmptyString(Article article) {
		if (article.getTitle() == null){
			article.setTitle("");
		}
	}

	@Before("aop.xyz.myapp.article.PointCuts.delPointcut() && args(article)")
	public void idShouldNotBeBlank(Article article){
		if (article.getId() == null){
			throw new IllegalArgumentException("Id should not be blank.");
		}
	}
}
